<?php
/**
 * Sistema Apicola
 * Modelo de Asociaciones
 */
class Asociacion extends AppModel {

    var $name = 'Asociacion';
    var $useTable = 'asociaciones';
    var $primaryKey = 'id';
    var $displayField = 'nombre_asociacion';
    var $recursive = 0;
    var $order=array(
        'Asociacion.nombre_asociacion'=>'ASC'
    );

    var $validate = array(
        'nombre_asociacion' =>array(
            array('rule'=>'notEmpty','message'=>'Debe completar este dato.')
        )
    );


    //The Associations below have been created with all possible keys, those that are not needed can be removed
    var $belongsTo= array(
        'Productor' => array(
            'className' => 'Productor',
            'foreignKey' => 'productor_id'
        )
    );

    public function beforeSave(){
        if(!empty($this->data['Asociacion'])){
            foreach($this->data['Asociacion'] as $campo=>$valor){
                $this->data['Asociacion'][$campo]=strtoupper($valor);
            }
        }
        return true;
    }

}
?>